package cn.cqautotest.cqviehelper.adapters;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.zhuangfei.timetable.listener.OnDateBuildAapter;

import cn.cqautotest.cqviehelper.R;
import cn.cqautotest.cqviehelper.base.BaseApplication;

/**
 * 自定义实现日期栏显示的样式
 */
public class MyOnDateBuildAdapter extends OnDateBuildAapter {

    private TextView[] weekViews = new TextView[8];

    @Override
    protected View onBuildDayLayout(LayoutInflater mInflate, int pos, int width, int height) {
        View layout = super.onBuildDayLayout(mInflate, pos, width, height);
        weekViews[pos] = layout.findViewById(R.id.id_week_day);
        return layout;
    }

    /**
     * 当前天 周 和 日 的字体颜色
     *
     * @param weekDay 当前天所在当前周中的索引
     */
    @Override
    protected void activeDateBackground(int weekDay) {
        if (textViews.length > weekDay && textViews[weekDay] != null && weekViews[weekDay] != null) {
            int color = ContextCompat.getColor(BaseApplication.getContext(), R.color.blue);
            weekViews[weekDay].setTextColor(color);
            textViews[weekDay].setTextColor(color);
        }
    }
}
